/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package tletlis.network;
import java.net.*;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * A simple class that can be used to get ip-address or local computer name
 * of a local computer
 * @author Max
 */
public class MyIp {

    /**
     * The InetAddress of the local computer
     */
    private InetAddress address;

   /**
    * The constructor initializes the address value.
    */
    public MyIp(){
        try {
             address = InetAddress.getLocalHost();
        } catch (UnknownHostException ex) {
            Logger.getLogger(MyIp.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    /**
     * A method that returns the ip-address of the local computer
     * @return string containing the ip-address
     */
    public String getMyIp(){
        String ip=address.getHostAddress();
        return ip;
    }

    /**
     * A method that returns the local computer name.
     * @return string with computer name
     */
    public String getMyLocalName(){
        String name= address.getHostName();
        return name;
    }

}
